import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import uView from '@/uni_modules/uview-ui'
import Tips from './common/util/Tips.js'
import util from './common/util/util.js'
import router from './common/router'
import {
	RouterMount
} from 'uni-simple-router'
import store from '@/store/index.js'
import api from '@/api/api.js'
import { isPlainObject } from '@/common/luch-request/utils.js'
import { initPlayerData } from '@/common/data/dataModule.js'

Vue.use(uView)
Vue.use(Tips)
Vue.use(api)

Vue.prototype.$Utils = util;
Vue.prototype.$store = store;

Vue.config.productionTip = false
App.mpType = 'app'

// 全局mixins
Vue.mixin({
	computed: {
		_hasLogin() {
			return this.$store.state.userinfo.cardNumber
		},
		_userinfo() {
			return this.$store.state.userinfo
		},
	},
	methods: {
		formatCardNum(num, char) {
			return util.formatCardNum(num, char);
		},
		priceFormat(price) {
			if (!price) return price;
			return uni.$u.priceFormat(price, 2)
		},
		initUserinfo() {
			initPlayerData();
		}
	}
})

const app = new Vue({
	store,
	...App
})
// #ifdef H5
RouterMount(app, '#app');
// #endif

// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
